package com.definity.toolkit.ui.widget;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JPasswordField;

import com.definity.toolkit.ui.Body;

public class PasswordField extends JPasswordField implements Widget<PasswordField> {

	private static final long serialVersionUID = 1580688964550407633L;

	public PasswordField() {

	}
	
	@Override
	public String id() {
		return getName();
	}

	@Override
	public PasswordField id(String id) {
		setName(id);
		return this;
	}

	@Override
	public PasswordField properties(Body<PasswordField> body) {
		body.content(this);
		return this;
	}

	@Override
	public PasswordField size(int width, int height) {
		setPreferredSize(new Dimension(width, height));
		return this;
	}
	
	public String text() {
		return new String(getPassword());
	}
	
	public PasswordField text(String text) {
		setText(text);
		return this;
	}

	@Override
	public Color background() {
		return getBackground();
	}

	@Override
	public PasswordField background(Color background) {
		setBackground(background);
		return this;
	}

	@Override
	public Color foreground() {
		return getForeground();
	}

	@Override
	public PasswordField foreground(Color foreground) {
		setForeground(foreground);
		return this;
	}

	@Override
	public Font font() {
		return getFont();
	}

	@Override
	public PasswordField font(Font font) {
		setFont(font);
		return this;
	}

}
